
#if 0
//***: MessageCallback(out, out ,out ,out ,out)
BOOL CALLBACK MessageCallback3(LONG lCommand, NET_DVR_ALARMER *pAlarmer, char *pAlarmInfo, DWORD dwBufLen, void* pUser) 
{        
	switch(lCommand)      
	{                
		case COMM_THERMOMETRY_ALARM: //温度预警或者温度报警         
		{            
			NET_DVR_THERMOMETRY_ALARM struThermometryAlarm = {0};             
			memcpy(&struThermometryAlarm, pAlarmInfo, sizeof(NET_DVR_THERMOMETRY_ALARM));             
			if (0 == struThermometryAlarm.byRuleCalibType)             
			{                 
				printf("点测温: Channel:%d, RuleID:%d,\n\
							ThermometryUnit:%d,\n\
							PresetNo:%d,\n\
							RuleTemperature:%.1f,\n\
							CurrTemperature:%.1f, \n\
							PTZ Info[Pan:%f, Tilt:%f, Zoom:%f],\n\
							AlarmLevel:%d, \n\
							AlarmType:%d, \n\
							AlarmRule:%d, \n\
							RuleCalibType:%d,  \n\
							Point[x:%f, y:%f], \n\
							PicLen:%d,\n\
							ThermalPicLen:%d, \n\
							ThermalInfoLen:%d\n", 
							struThermometryAlarm.dwChannel,
							struThermometryAlarm.byRuleID, 
							struThermometryAlarm.byThermometryUnit, 
							struThermometryAlarm.wPresetNo, 
							struThermometryAlarm.fRuleTemperature, 
							struThermometryAlarm.fCurrTemperature, 
							struThermometryAlarm.struPtzInfo.fPan,
							struThermometryAlarm.struPtzInfo.fTilt, 
							struThermometryAlarm.struPtzInfo.fZoom,
							struThermometryAlarm.byAlarmLevel, struThermometryAlarm.byAlarmType,
							struThermometryAlarm.byAlarmRule, struThermometryAlarm.byRuleCalibType,
							struThermometryAlarm.struPoint.fX, struThermometryAlarm.struPoint.fY,
							struThermometryAlarm.dwPicLen, struThermometryAlarm.dwThermalPicLen,
							struThermometryAlarm.dwThermalInfoLen);                        
				}             
			else if (1 == struThermometryAlarm.byRuleCalibType || 2 == struThermometryAlarm.byRuleCalibType)             
			{                 
				int iPointNum = struThermometryAlarm.struRegion.dwPointNum;                 
				for (int i = 0; i < iPointNum; i++)                 
				{                     
					float fX = struThermometryAlarm.struRegion.struPos[i].fX;                     
					float fY = struThermometryAlarm.struRegion.struPos[i].fY;                     
					printf("测温区域坐标点:X%d:%f,Y%d:%f;", iPointNum + 1, fX, iPointNum + 1, fY);                 
				}
				print("...\n");                
				printf("线测温或者框测温:\n Channel:%d\n", struThermometryAlarm.dwChannel);
				printf("  RuleID:%d\n", struThermometryAlarm.byRuleID);
				printf("  HighestPoint[x:%f, y:%f]\n", struThermometryAlarm.struHighestPoint.fX,struThermometryAlarm.struHighestPoint.fY);
				printf("  ThermometryUnit:%d\n", struThermometryAlarm.byThermometryUnit);
				printf("  PresetNo:%d\n", struThermometryAlarm.wPresetNo);
				printf("  RuleTemperature:%.1f\n", struThermometryAlarm.fRuleTemperature);
				printf("  CurrTemperature:%.1f\n", struThermometryAlarm.fCurrTemperature);
				printf("  PTZ Info[Pan:%f, Tilt:%f, Zoom:%f]\n", struThermometryAlarm.byRuleID,struThermometryAlarm.struPtzInfo.fTilt,struThermometryAlarm.struPtzInfo.fZoom);
				printf("  AlarmLevel:%d\n", struThermometryAlarm.byAlarmLevel);
				printf("  AlarmType:%d\n", struThermometryAlarm.byAlarmType);
				printf("  AlarmRule:%d\n", struThermometryAlarm.byAlarmRule);
				printf("  RuleCalibType:%d\n", struThermometryAlarm.byRuleCalibType);
				printf("  PicLen:%d\n", struThermometryAlarm.dwPicLen);
				printf("  ThermalPicLen:%d\n", struThermometryAlarm.dwThermalPicLen);
				printf("  ThermalInfoLen:%d\n", struThermometryAlarm.dwThermalInfoLen);
			}
			break;         
		} //case            
		case COMM_THERMOMETRY_DIFF_ALARM: //温差报警         
		{
			NET_DVR_THERMOMETRY_DIFF_ALARM struThermometryDiffAlarm = {0};             
			memcpy(&struThermometryDiffAlarm, pAlarmInfo, sizeof(NET_DVR_THERMOMETRY_DIFF_ALARM));  
          
			if (0 == struThermometryDiffAlarm.byRuleCalibType)             
			{                 
				printf("温差报警: Channel:%d, AlarmID1:%d, AlarmID2:%d, PresetNo:%d, RuleTemperatureDiff:%.1f, \
				CurTemperatureDiff:%.1f, AlarmLevel:%d, AlarmType:%d, AlarmRule:%d, RuleCalibType:%d, \
				Point1[x:%f, y:%f], point2[x:%f, y:%f], PTZ Info[Pan:%f, Tilt:%f, Zoom:%f], PicLen:%d, \
				                 ThermalPicLen:%d, ThermalInfoLen:%d, ThermometryUnit:%d", struThermometryDiffAlarm.dwChannel, \
								 struThermometryDiffAlarm.byAlarmID1, struThermometryDiffAlarm.byAlarmID2, \
								 struThermometryDiffAlarm.wPresetNo, struThermometryDiffAlarm.fRuleTemperatureDiff, \
								 struThermometryDiffAlarm.fCurTemperatureDiff, struThermometryDiffAlarm.byAlarmLevel, \
								 struThermometryDiffAlarm.byAlarmType, struThermometryDiffAlarm.byAlarmRule, \
								 struThermometryDiffAlarm.byRuleCalibType, struThermometryDiffAlarm.struPoint[0].fX, \
								 struThermometryDiffAlarm.struPoint[0].fY, struThermometryDiffAlarm.struPoint[1].fX, \
								 struThermometryDiffAlarm.struPoint[1].fY, struThermometryDiffAlarm.struPtzInfo.fPan, \
								 struThermometryDiffAlarm.struPtzInfo.fTilt, struThermometryDiffAlarm.struPtzInfo.fZoom, \
								 struThermometryDiffAlarm.dwPicLen, struThermometryDiffAlarm.dwThermalPicLen, \
								 struThermometryDiffAlarm.dwThermalInfoLen, struThermometryDiffAlarm.byThermometryUnit);            
			}             
			else if (1 == struThermometryDiffAlarm.byRuleCalibType || 2 == struThermometryDiffAlarm.byRuleCalibType)             
			{                 
				int i = 0;                 
				int iPointNum = struThermometryDiffAlarm.struRegion[0].dwPointNum;                 
				for (i = 0; i < iPointNum; i++)                 
				{                     
					float fX = struThermometryDiffAlarm.struRegion[0].struPos[i].fX;                     
					float fY = struThermometryDiffAlarm.struRegion[0].struPos[i].fY;                     
					printf("测温区域1坐标点: X%d:%f,Y%d:%f;\n", iPointNum + 1, fX, iPointNum + 1, fY);                 
				}                 
				iPointNum = struThermometryDiffAlarm.struRegion[1].dwPointNum;                 
				for (i = 0; i < iPointNum; i++)                 
				{                     
					float fX = struThermometryDiffAlarm.struRegion[1].struPos[i].fX;                     
					float fY = struThermometryDiffAlarm.struRegion[1].struPos[i].fY;                     
					printf("测温区域2坐标点: X%d:%f,Y%d:%f;\n", iPointNum + 1, fX, iPointNum + 1, fY);                 
				}    
				        
			}

			break;         
		}             
		default:
		{          
			printf("其他报警，报警信息类型: %d\n", lCommand);             
			break;
		}  
	}//switch   
	return TRUE; 
}


#endif
#if 0
BOOL CALLBACK MessageCallback2(LONG lCommand, NET_DVR_ALARMER *pAlarmer, char *pAlarmInfo, DWORD dwBufLen, void* pUser)
{
    NET_DVR_JPEGPARA strPicPara = {0};
	strPicPara.wPicQuality = 0;	//图片质量系数：0-最好，1-较好，2-一般 
	strPicPara.wPicSize = 500;	//500-384*288

    int i;
    switch (lCommand)
    {
        case COMM_THERMOMETRY_ALARM: //温度预警或者温度报警
        {
            //NET_DVR_FIRE
            NET_DVR_THERMOMETRY_ALARM struThermometryAlarm = { 0 };
			memcpy(&struThermometryAlarm, pAlarmInfo, sizeof(NET_DVR_THERMOMETRY_ALARM));

            if (0 == struThermometryAlarm.byRuleCalibType)
			{
				printf("Dot type temp detect!!!");
			}
			else if (1 == struThermometryAlarm.byRuleCalibType || 2 == struThermometryAlarm.byRuleCalibType)
            {
                string localTime = getLocalTime_self();
                const string filePathName = alarmPath + "/" + localTime + ".jpg";

                int iRet = NET_DVR_CaptureJPEGPicture(LUserID, struDeviceInfoV40.struDeviceV30.byStartChan, &strPicPara, 
                                                        const_cast<char*>(filePathName.c_str()));

                printf("Alarm: HighestPoint[x:%f, y:%f], CurrTemp:%.1f, RuleTemp:%.1f, AlarmLevel:%d, AlarmType:%d, AlarmRule:%d, RuleCalibType:%d\n", 
                        struThermometryAlarm.struHighestPoint.fX, 
                        struThermometryAlarm.struHighestPoint.fY, 
                        struThermometryAlarm.fCurrTemperature, 
                        struThermometryAlarm.fRuleTemperature, 
                        struThermometryAlarm.byAlarmLevel, 
                        struThermometryAlarm.byAlarmType,
                        struThermometryAlarm.byAlarmRule, 
                        struThermometryAlarm.byRuleCalibType);

                if (!iRet)
				{
					printf("Alarm: NET_DVR_CaptureJPEGPicture failed, error code: %d iRet: %d", NET_DVR_GetLastError(), iRet);
				}
				else
				{
					printf("Alarm: NET_DVR_CaptureJPEGPicture success! iRet: %d\n", iRet);
				}
/*
				uint8 AlarmLevel	#0-预警 1-报警
				uint8 AlarmType		#报警类型 0-最高温度 1-最低温度 2-平均温度 3-温差 4-温度突升 5-温度突降
				uint8 AlarmRule		#0-大于 1-小于
				uint8 RuleCalibType	#规则标定类型 0-点 1-框 2-线
*/
                int iPointNum = struThermometryAlarm.struRegion.dwPointNum;
                for(int i=0; i<iPointNum; i++)
                {
                    const float fx = struThermometryAlarm.struRegion.struPos[i].fX;
                    const float fy = struThermometryAlarm.struRegion.struPos[i].fY;
                    printf("test region points:X%d:%f, Y%d:%f;", iPointNum+1, fx, iPointNum+1, fy);
                    
                }

                //绘制温度警告区域 但这里相机如果快速运动 截图函数会滞后报警时刻图片 因此警告区域会偏移 后续再优化
                const float point_x = struThermometryAlarm.struHighestPoint.fX ;
                const float point_y = struThermometryAlarm.struHighestPoint.fY ;

				Mat image = imread(filePathName.c_str());
				Rect rect(point_x, point_y, 50, 50);	//左上坐标（x,y）和绘制矩形的长(x)宽(y) 默认图片尺寸384*288
				cv::rectangle(image, rect, Scalar(0, 255, 0), 1, LINE_8,0);	//图片 绘制矩形 RGB颜色 线条粗细 线型Line_8或者Line_4 坐标小数点位数

				//string imgPath;
				cv::imwrite(filePathName, image);

				cout << "thermalcam.cpp :: " << filePathName << endl;
				//matToString(image,imgStr, false, 1.0);
				pushAlarm(filePathName);
	   
            }
            break;
        }
        case COMM_THERMOMETRY_DIFF_ALARM:  
        {
            
        }

        default:
            printf("else alarm, alarm type: %d\n", lCommand);
            break;
    }
    return true;
}
#endif

void CALLBACK GetThermInfoCallback(DWORD dwType, void* lpBuffer, DWORD dwBufLen, void* pUserData) 
{     

	if (dwType == NET_SDK_CALLBACK_TYPE_DATA)     {         
		LPNET_DVR_THERMOMETRY_UPLOAD lpThermometry = new NET_DVR_THERMOMETRY_UPLOAD;         
		memcpy(lpThermometry, lpBuffer, sizeof(*lpThermometry));

		NET_DVR_TIME struAbsTime = {0};         
		struAbsTime.dwYear = GET_YEAR(lpThermometry->dwAbsTime);         
		struAbsTime.dwMonth = GET_MONTH(lpThermometry->dwAbsTime);        
		struAbsTime.dwDay = GET_DAY(lpThermometry->dwAbsTime);         
		struAbsTime.dwHour = GET_HOUR(lpThermometry->dwAbsTime);         
		struAbsTime.dwMinute = GET_MINUTE(lpThermometry->dwAbsTime);         
		struAbsTime.dwSecond = GET_SECOND(lpThermometry->dwAbsTime);          
		printf("实时测温结果:byRuleID[%d]wPresetNo[%d]byRuleCalibType[%d]byThermometryUnit[%d]byDataType[%d]"             
			"dwAbsTime[%4.4d%2.2d%2.2d%2.2d%2.2d%2.2d]\n", lpThermometry->byRuleID, lpThermometry->wPresetNo,  lpThermometry->byRuleCalibType,
			lpThermometry->byThermometryUnit, lpThermometry->byDataType,  struAbsTime.dwYear, struAbsTime.dwMonth, struAbsTime.dwDay,              
			struAbsTime.dwHour, struAbsTime.dwMinute, struAbsTime.dwSecond);           
			
		if(lpThermometry->byRuleCalibType==0) //点测温         
		{             
			printf("点测温信息:fTemperature[%f]\n", lpThermometry->struPointThermCfg.fTemperature);  
    
		}           
		if((lpThermometry->byRuleCalibType==1)||(lpThermometry->byRuleCalibType==2)) //框/线测温         
		{             
			printf("框/线测温信息:fMaxTemperature[%f]fMinTemperature[%f]fAverageTemperature[%f]fTemperatureDiff[%f]\n",                  
			lpThermometry->struLinePolygonThermCfg.fMaxTemperature,lpThermometry->struLinePolygonThermCfg.fMinTemperature,                 
			lpThermometry->struLinePolygonThermCfg.fAverageTemperature,lpThermometry->struLinePolygonThermCfg.fTemperatureDiff);  
			//***
			// mutexTempAlarm.lock();
			// TempMax = lpThermometry->struLinePolygonThermCfg.fMaxTemperature;
			// TempMin = lpThermometry->struLinePolygonThermCfg.fMinTemperature;
			// TempAvg = lpThermometry->struLinePolygonThermCfg.fAverageTemperature;
			// TempDiff = lpThermometry->struLinePolygonThermCfg.fTemperatureDiff;
			// mutexTempAlarm.unlock();

			//***     
  
		}                 
		if (lpThermometry != NULL)         
		{             
			delete lpThermometry;             
			lpThermometry = NULL;         
		}     


	}   //if
	else if (dwType == NET_SDK_CALLBACK_TYPE_STATUS)     
	{         
		DWORD dwStatus = *(DWORD*)lpBuffer;         
		if (dwStatus == NET_SDK_CALLBACK_STATUS_SUCCESS)         
		{             
			printf("dwStatus:NET_SDK_CALLBACK_STATUS_SUCCESS\n");                     
		}         
		else if (dwStatus == NET_SDK_CALLBACK_STATUS_FAILED)         
		{             
			DWORD dwErrCode = *(DWORD*)((char *)lpBuffer + 4);             
			printf("NET_DVR_GET_MANUALTHERM_INFO failed, Error code %d\n", dwErrCode);         
		}     
	} 
} 

#if 0
bool getIsTempAlarm()
{
	unique_lock<mutex>lock(mutexTempAlarm);//automatically calls lock on mtx
	return isTempAlarm;
}
//val set false
void popAlarm(string &str)
{
	unique_lock<mutex>lock(mutexTempAlarm);//automatically calls lock on mtx
	isTempAlarm = false;
	//memcpy(&str[0], alarmImg, str.length() + 1); // 注意，一定要加1，否则没有赋值'\0'
	str = mainTempAlarmImage;
	memset(mainTempAlarmImage, 0, sizeof(mainTempAlarmImage));
}


void RealTempDetect()
{
	//启动实时温度检测
	NET_DVR_REALTIME_THERMOMETRY_COND struThermCond = { 0 };
	struThermCond.dwSize = sizeof(struThermCond);
	struThermCond.byRuleID = 1;       //规则ID，0代表获取全部规则，具体规则ID从1开始
	struThermCond.dwChan = dwChannel; 	  //从1开始，0xffffffff代表获取全部通道
	struThermCond.byMode = 1;			//长连接模式：0- 保留（兼容不支持该功能的老设备），1- 定时模式，2-  温差模式
	/*
	1-定时模式：设备每隔一秒上传各个规则测温数据的最高温、最低温和平均温度值、温差。
	2-温差模式：若上一秒与下一秒的最高温或者最低温或者平均温或者温差值的温差大于等于2摄氏度，
				则上传最高温、最低温和平均温度值；若大于等于一个小时温差值均小于2摄氏度，则上传最高温、最低温、平均温和温差值  
	*/
	LHandle_realtemp = NET_DVR_StartRemoteConfig(LUserID, NET_DVR_GET_REALTIME_THERMOMETRY, &struThermCond, sizeof(struThermCond), GetThermInfoCallback, NULL);
	if (LHandle_realtemp < 0)
	{
		printf("NET_DVR_GET_REALTIME_THERMOMETRY failed, error code: %d lHandle: %d\n", NET_DVR_GetLastError(), LHandle_realtemp);
	}
	else
	{
		printf("NET_DVR_GET_REALTIME_THERMOMETRY success! lHandle: %d\n", LHandle_realtemp);
	}
    sleep(0.1);



}

	//string path = alarmPath + "/xx.jpg";
	//res = capPicture(LUserID,struDeviceInfoV40,path.c_str());
	//cout << "picture has collected in Path: " << path << endl;



int thermal::AlarmDetect(const int lUserId)
{
 //set alarm callback function
	NET_DVR_SetDVRMessageCallBack_V51(0, MessageCallback3, NULL);
	
	LONG lHandle;
    NET_DVR_SETUPALARM_PARAM_V50 struSetupAlarmParam = { 0 };
	struSetupAlarmParam.dwSize = sizeof(struSetupAlarmParam);
	struSetupAlarmParam.byRetVQDAlarmType = TRUE; //Prefer VQD Alarm type of NET_DVR_VQD_ALARM
	struSetupAlarmParam.byRetAlarmTypeV40 = TRUE;
	struSetupAlarmParam.byFaceAlarmDetection = 1;//m_comFaceAlarmType.GetCurSel();
                
    struSetupAlarmParam.byRetDevInfoVersion = TRUE;
    struSetupAlarmParam.byAlarmInfoType = 1;
    struSetupAlarmParam.bySupport = 4;
    lHandle = NET_DVR_SetupAlarmChan_V50(lUserId, &struSetupAlarmParam, NULL, 0);

	if (lHandle < 0)
	{
		printf("NET_DVR_SetupAlarmChan_V50 error, %d\n", NET_DVR_GetLastError());
		NET_DVR_Logout(lUserId);
		NET_DVR_Cleanup(); 
		return -1;
	}

	return 0;
}



void run(void* arg)
{
	string exe_path;
	thermal_get_exe_path(exe_path,2);
	//cout << "exe path:  " <<exe_path << endl;

    //DWORD dwChannel = 2;  //热成像通道      
    //---------------------------------------     
    //初始化     
    NET_DVR_Init();      
    //设置连接时间与重连时间     
    NET_DVR_SetConnectTime(2000, 1);     
    NET_DVR_SetReconnect(10000, true);      
    //---------------------------------------     
    //注册设备(监听报警可以不注册)     
    LONG lUserID;     
    NET_DVR_DEVICEINFO_V30 struDeviceInfo;     
    lUserID = NET_DVR_Login_V30("192.168.1.64 ", 8000, "admin", "abcd1234", &struDeviceInfo);     
    if (lUserID < 0)     {         
        printf("Login error, %d\n", NET_DVR_GetLastError());         
        NET_DVR_Cleanup();          
        return;    
    }
    else{
        printf("login success\n");
    }      
    //启动实时温度检测     
    NET_DVR_REALTIME_THERMOMETRY_COND struThermCond = {0};     
    struThermCond.dwSize = sizeof(struThermCond);     
    struThermCond.byRuleID = 1;       //规则ID，0代表获取全部规则，具体规则ID从1开始     
    struThermCond.dwChan = 2; //从1开始，0xffffffff代表获取全部通道      
    LONG lHandle = NET_DVR_StartRemoteConfig(lUserID, NET_DVR_GET_REALTIME_THERMOMETRY, &struThermCond, sizeof(struThermCond), GetThermInfoCallback2, NULL); 
    if (lHandle < 0)    
    {         
        printf("NET_DVR_GET_REALTIME_THERMOMETRY failed, error code: %d\n", NET_DVR_GetLastError());     
    }     
    else     
    {         
        printf("NET_DVR_GET_REALTIME_THERMOMETRY is successful!");     
    }      
    
    printf("waint moment");
    cin.get();  //等待一段时间，接收实时测温结果      
    
    //关闭长连接配置接口所创建的句柄，释放资源     
    if(!NET_DVR_StopRemoteConfig(lHandle))     
    {         
        printf("NET_DVR_StopRemoteConfig failed, error code: %d\n", NET_DVR_GetLastError());     
    }      
    //注销用户，如果前面没有登录，该步骤则不需要     
    NET_DVR_Logout(lUserID);      
    //释放SDK资源     
    NET_DVR_Cleanup();      
    return; 
    
}

void run2() {     //---------------------------------------     
    // 初始化     
    NET_DVR_Init();     
    //设置连接时间与重连时间     
    NET_DVR_SetConnectTime(2000, 1);     
    NET_DVR_SetReconnect(10000, true);      
    //---------------------------------------     
    // 注册设备     
    LONG lUserID;      
    //登录参数，包括设备地址、登录用户、密码等     
    NET_DVR_USER_LOGIN_INFO struLoginInfo = {0};     
    struLoginInfo.bUseAsynLogin = 0; //同步登录方式     
    strcpy(struLoginInfo.sDeviceAddress, "192.168.1.64"); //设备IP地址     
    struLoginInfo.wPort = 8000; //设备服务端口     
    strcpy(struLoginInfo.sUserName, "admin"); //设备登录用户名     
    strcpy(struLoginInfo.sPassword, "abcd1234"); //设备登录密码        
    //设备信息, 输出参数     
    NET_DVR_DEVICEINFO_V40 struDeviceInfoV40 = {0};      
    lUserID = NET_DVR_Login_V40(&struLoginInfo, &struDeviceInfoV40);     
    if (lUserID < 0)     {         
        printf("Login failed, error code: %d\n", NET_DVR_GetLastError());         
        NET_DVR_Cleanup();         
        return;     
    }       
    //设置报警回调函数     
    NET_DVR_SetDVRMessageCallBack_V31(MessageCallback3, NULL);        
    //启用布防     
    LONG lHandle;     
    NET_DVR_SETUPALARM_PARAM  struAlarmParam={0};     
    struAlarmParam.dwSize=sizeof(struAlarmParam);     
    //温度或者温差报警不需要设置其他报警布防参数，不支持      
    lHandle = NET_DVR_SetupAlarmChan_V41(lUserID, & struAlarmParam);     
    if (lHandle < 0)     {         
        printf("NET_DVR_SetupAlarmChan_V41 error, %d\n", NET_DVR_GetLastError());         
        NET_DVR_Logout(lUserID);         
        NET_DVR_Cleanup();          
        return;     
    }        
    cin.get(); //等待过程中，如果设备上传报警信息，在报警回调函数里面接收和处理报警信息      
    
    //撤销布防上传通道     
    if (!NET_DVR_CloseAlarmChan_V30(lHandle))     {         
        printf("NET_DVR_CloseAlarmChan_V30 error, %d\n", NET_DVR_GetLastError());         
        NET_DVR_Logout(lUserID);         
        NET_DVR_Cleanup();          
        return;     
    }        
    //注销用户     
    NET_DVR_Logout(lUserID);     
    //释放SDK资源     
    NET_DVR_Cleanup();     
    return; 
} 



void CALLBACK GetThermInfoCallback2(DWORD dwType, void* lpBuffer, DWORD dwBufLen, void* pUserData) 
{     

	if (dwType == NET_SDK_CALLBACK_TYPE_DATA)     {         
		LPNET_DVR_THERMOMETRY_UPLOAD lpThermometry = new NET_DVR_THERMOMETRY_UPLOAD;         
		memcpy(lpThermometry, lpBuffer, sizeof(*lpThermometry));

		NET_DVR_TIME struAbsTime = {0};         
		struAbsTime.dwYear = GET_YEAR(lpThermometry->dwAbsTime);         
		struAbsTime.dwMonth = GET_MONTH(lpThermometry->dwAbsTime);        
		struAbsTime.dwDay = GET_DAY(lpThermometry->dwAbsTime);         
		struAbsTime.dwHour = GET_HOUR(lpThermometry->dwAbsTime);         
		struAbsTime.dwMinute = GET_MINUTE(lpThermometry->dwAbsTime);         
		struAbsTime.dwSecond = GET_SECOND(lpThermometry->dwAbsTime);          
		printf("实时测温结果:byRuleID[%d]wPresetNo[%d]byRuleCalibType[%d]byThermometryUnit[%d]byDataType[%d]"             
			"dwAbsTime[%4.4d%2.2d%2.2d%2.2d%2.2d%2.2d]\n", lpThermometry->byRuleID, lpThermometry->wPresetNo,  lpThermometry->byRuleCalibType,
			lpThermometry->byThermometryUnit, lpThermometry->byDataType,  struAbsTime.dwYear, struAbsTime.dwMonth, struAbsTime.dwDay,              
			struAbsTime.dwHour, struAbsTime.dwMinute, struAbsTime.dwSecond);           
			
		if(lpThermometry->byRuleCalibType==0) //点测温         
		{             
			printf("点测温信息:fTemperature[%f]\n", lpThermometry->struPointThermCfg.fTemperature);  
    
		}           
		if((lpThermometry->byRuleCalibType==1)||(lpThermometry->byRuleCalibType==2)) //框/线测温         
		{             
			printf("框/线测温信息:fMaxTemperature[%f]fMinTemperature[%f]fAverageTemperature[%f]fTemperatureDiff[%f]\n",                  
			lpThermometry->struLinePolygonThermCfg.fMaxTemperature,lpThermometry->struLinePolygonThermCfg.fMinTemperature,                 
			lpThermometry->struLinePolygonThermCfg.fAverageTemperature,lpThermometry->struLinePolygonThermCfg.fTemperatureDiff);  
			//***
			// mutexTempAlarm.lock();
			// TempMax = lpThermometry->struLinePolygonThermCfg.fMaxTemperature;
			// TempMin = lpThermometry->struLinePolygonThermCfg.fMinTemperature;
			// TempAvg = lpThermometry->struLinePolygonThermCfg.fAverageTemperature;
			// TempDiff = lpThermometry->struLinePolygonThermCfg.fTemperatureDiff;
			// mutexTempAlarm.unlock();

			//***     
  
		}                 
		if (lpThermometry != NULL)         
		{             
			delete lpThermometry;             
			lpThermometry = NULL;         
		}     


	}   //if
	else if (dwType == NET_SDK_CALLBACK_TYPE_STATUS)     
	{         
		DWORD dwStatus = *(DWORD*)lpBuffer;         
		if (dwStatus == NET_SDK_CALLBACK_STATUS_SUCCESS)         
		{             
			printf("dwStatus:NET_SDK_CALLBACK_STATUS_SUCCESS\n");                     
		}         
		else if (dwStatus == NET_SDK_CALLBACK_STATUS_FAILED)         
		{             
			DWORD dwErrCode = *(DWORD*)((char *)lpBuffer + 4);             
			printf("NET_DVR_GET_MANUALTHERM_INFO failed, Error code %d\n", dwErrCode);         
		}     
	} 
} 


#endif